package com.lw.spring.javademo.trans;


import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;
@WebServlet("/second")
public class SecondServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 获取请求属性
        String message = (String) request.getAttribute("message");
        // 设置响应内容类型
        response.setContentType("text/html");
        // 获取输出流，返回响应数据
        PrintWriter out = response.getWriter();
        out.println("<html><body>");
        out.println("<h1>Received message: " + message + "</h1>");
        out.println("</body></html>");
    }
}

